package com.wn.quality.configuration;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wuqingting
 * @date 2022/10/19
 */
@Configuration
public class RabbitmqConfiguration {
    @Bean//配置消息转换器
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }

    @Bean//声明topic交换机
    public TopicExchange topicExchange(){
        return new TopicExchange("qualityExchange");
    }

    @Bean//声明队列
    public Queue ncrQueue(){
        return new Queue("ncrAddQueue");
    }

    @Bean//绑定队列到交换机
    public Binding bindingNcr(Queue ncrQueue,TopicExchange topicExchange){
        return BindingBuilder.bind(ncrQueue).to(topicExchange).with("#.ncr.#");
    }

}
